package com.heather.exam.controller;

import com.heather.exam.models.Admin;

import java.util.Scanner;

//创建管理员登录界面AdminLogin，用于输入管理员的用户名和密码
public class AdminLogin {

        public static void main(String[] args) {
            // 创建一个管理员对象
            Admin admin = new Admin("admin", "adminpass");

            // 模拟管理员登录
            Scanner scanner = new Scanner(System.in);
            System.out.print("Enter username: ");
            String username = scanner.nextLine();
            System.out.print("Enter password: ");
            String password = scanner.nextLine();

            // 验证管理员身份
            if (admin.authenticate(username, password)) {
                System.out.println("Login successful!");

                // 进行编写公告的操作
                System.out.print("Enter announcement: ");
                String announcement = scanner.nextLine();
                admin.writeAnnouncement(announcement);
            } else {
                System.out.println("Login failed. Invalid credentials.");
            }
        }

}
